package com.codeoss.module.product.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.codeoss.module.product.response.AttributeSetInstanceComponentResponse;
import com.codeoss.module.product.service.IAttributeSetInstanceComponentService;

@Controller
@RequestMapping("attributesetinstance")
public class AttributeSetInstanceComponentController {
	@Autowired
	private IAttributeSetInstanceComponentService attributeSetInstanceService;
	
	@RequestMapping(value = "init", method = RequestMethod.GET)
	@ResponseBody
	public AttributeSetInstanceComponentResponse init(@RequestParam("pageCode") String pageCode,@RequestParam("productProductId") Long productProductId,
			@RequestParam(value="productAttributeSetId",required = false) Long productAttributeSetId,@RequestParam(value = "productAttributeSetInstanceId", required = false) Long productAttributeSetInstanceId){
		AttributeSetInstanceComponentResponse attributeSetInstanceResponse=attributeSetInstanceService.init(pageCode,productProductId,productAttributeSetId,productAttributeSetInstanceId);
		return attributeSetInstanceResponse;
	}
	
	@RequestMapping(value = "dataSave", method = RequestMethod.POST)
	@ResponseBody
	public AttributeSetInstanceComponentResponse dataSave(@RequestParam("pageCode") String pageCode,@RequestParam("productProductId") Long productProductId,
			@RequestParam(value="productAttributeSetId",required = false) Long productAttributeSetId,
			@RequestParam(value = "productAttributeSetInstanceId", required = false) Long productAttributeSetInstanceId,@RequestParam Map<String,String> paraMap){
		AttributeSetInstanceComponentResponse attributeSetInstanceResponse=attributeSetInstanceService.dataSave(pageCode,productProductId,productAttributeSetId,productAttributeSetInstanceId,paraMap);
		return attributeSetInstanceResponse;
	}
}
